package com.sloera.gamestart.taobao;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.annotation.Nullable;

import com.sloera.gamestart.R;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_taobao);
        Button saveBtn = findViewById(R.id.save);
        saveBtn.setOnClickListener(v -> {
            String site1 = ((EditText)findViewById(R.id.et_site1)).getText().toString();
            String street = ((EditText)findViewById(R.id.et_street)).getText().toString();
            String detail = ((EditText)findViewById(R.id.et_detail)).getText().toString();
            String name = ((EditText)findViewById(R.id.et_receiver_name)).getText().toString();
            String tel = ((EditText)findViewById(R.id.et_receiver_tel)).getText().toString();
            String email = ((EditText)findViewById(R.id.et_email)).getText().toString();

            if (!"".equals(site1) && !"".equals(street) && !"".equals(detail) && !"".equals(name) && !"".equals(tel) && !"".equals(email)) {
                Intent intent = new Intent(MainActivity.this, AddressActivity.class);
                Bundle bundle = new Bundle();
                bundle.putCharSequence("name", name);
                bundle.putCharSequence("tel", tel);
                bundle.putCharSequence("site1", site1);
                bundle.putCharSequence("street", street);
                bundle.putCharSequence("detail", detail);
                bundle.putCharSequence("email", email);
                intent.putExtras(bundle);
                startActivity(intent);
            } else {
                Toast.makeText(MainActivity.this, "请将收货地址填写完整。", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
